import App from './App'
// import uviewPlus from 'uview-plus'
import {
	createPinia
} from 'pinia'
import {
	createSSRApp
} from 'vue'
import {
	useMineStore
} from '@/stores/modules/mine'
export function createApp() {
	const app = createSSRApp(App)
	const pinia = createPinia()
	app.use(pinia)

	uni.getSystemInfo({
		success: res => {
			let systemHeight = 0
			// 获取状态栏高度
			app.config.globalProperties.$statusHeight = parseInt(
				res.statusBarHeight * 2
			)
			// 设备高度
			const uniPlatform = res.uniPlatform
			if (uniPlatform == "mp-weixin") {
				systemHeight = '100vh'
			}
			app.config.globalProperties.$systemInfo = {
				systemHeight: res.screenHeight,
				autoHeight: res.windowHeight - res.safeAreaInsets.top - 1
			}
		}
	})

	const mineStore = useMineStore()
	app.config.globalProperties = mineStore;
	//设置底部导航中间凸起按钮
	app.config.globalProperties.authJump = (options) => {
		if (!mineStore.state.token) {
			uni.showToast({
				title: '请先登录',
				icon: 'none'
			});
			return uni.navigateTo({
				url: '/pages/login/login'
			});
		}
		uni.navigateTo(options);
	}

	// 配置websocketURL
	// app.config.globalProperties.$socketURL = 'ws://www.zjxcqczl.com/some-action'
	return {
		app
	}
}